package com.example.indyapp;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
	
	Button plus, minus;
	TextView anzeige;
	int zaehler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        zaehler = 0;
        plus = (Button)findViewById(R.id.bPlus);
        minus = (Button)findViewById(R.id.bMinus);        
        anzeige = (TextView)findViewById(R.id.tvAnzeige);
        
        plus.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				zaehler += 1;
				//Bei SetText(INTEGER) unbedingt wie folgt vorgehen:
				anzeige.setText(String.valueOf(zaehler));
			}
		});
        
        minus.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				zaehler -= 1;
				anzeige.setText(String.valueOf(zaehler));
			}
		});
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
